package com.weilive.core.utils.ini;

import java.util.ArrayList;
import java.util.List;

public class SectionData {
	private List<KeyData> keyData = new ArrayList<KeyData>();
	private String sectionName;

	public String getSectionName() {
		return this.sectionName;
	}

	public void setSectionName(String sectionName) {
		this.sectionName = sectionName;
	}

	public boolean setKeyValue(int title, String value) {
		KeyData data = (KeyData) this.keyData.get(title);
		if (data == null) {
			return false;
		}

		data.setValue(value);
		return true;
	}

	public boolean setKeyName(int title, String keyname) {
		KeyData data = (KeyData) this.keyData.get(title);
		if (data == null) {
			return false;
		}

		data.setKey(keyname);
		return true;
	}

	public boolean push(KeyData keydata) {
		return this.keyData.add(keydata);
	}

	public int getKeyCount() {
		return this.keyData.size();
	}

	public String getKeyName(int title) {
		KeyData data = (KeyData) this.keyData.get(title);
		if (data == null) {
			return "";
		}

		return data.getKey();
	}

	public String getKeyValue(int title) {
		KeyData data = (KeyData) this.keyData.get(title);
		if (data == null) {
			return "";
		}
		return data.getValue();
	}

	public boolean delKey(int title) {
		KeyData data = (KeyData) this.keyData.get(title);
		if (data == null) {
			return false;
		}
		this.keyData.remove(title);
		return true;
	}
}